package cn.mitool.core.domain.query;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

/**
 * 分页查询参数
 *
 * @author dragon
 * @version 1.0
 * @date 2024/6/24 15:37
 */
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
public class PaginationQuery {

    /**
     * 分页页数
     */
    @Builder.Default
    private Integer pageNum = 1;

    /**
     * 分页条数
     */
    @Builder.Default
    private Integer pageSize = 10;

    /**
     * 查询偏移量
     */
    @Builder.Default
    private Integer offset = 0;


    public Integer getOffset() {
        return (this.getPageNum() - 1) * this.getPageSize();
    }

}
